﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SMTC.BO.UserPower;
using System.Text.RegularExpressions;
using SMTC.WebCommon.Common;

public partial class Common_AddMounterMaintenance :  BasePage
{
    private InsertMounterMaintenance insertmaintenance = new InsertMounterMaintenance();
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void ButtonCancel_Click(object sender, EventArgs e)
    {
        Response.Write("<script language=javascript>self.close()</script>");
    }
    protected void ButtonOK_Click(object sender, EventArgs e)
    {
        if (CheckAbility(TextBoxAbility.Text.ToString().Trim()) ==false|| IsValidParameter(TextBoxParameter.Text.ToString().Trim())==false)
        {
            ClientScript.RegisterStartupScript(Page.GetType(), "", "AddFalse()", true);
          
        }

        else
        {
            insertmaintenance.Insert_Mounter_Maintenance(TextBoxMachineType.Text.ToString().Trim().ToUpper(), int.Parse(TextBoxAbility.Text.ToString().Trim()), TextBoxParameter.Text.ToString().Trim());
            ClientScript.RegisterStartupScript(Page.GetType(), "", "AddOK()", true);
        }
    }
    protected bool CheckAbility(string ability)
    {
        int f;
        return int.TryParse(ability, out f);
    
    }
    protected bool IsValidParameter(string parameter)
    {
        return Regex.IsMatch(parameter, @"^[0-9]+(.[0-9]{1,2}){1}$");


    }
}